-- magic.lua
-- Created by zouyb Mar/13/2015
-- 魔力提升统计

local handle = function(para)
    -- 如果不是在地牢内就忽略
    if not DungeonM.isInDungeon() then
        return;
    end

    local attrib = para.attrib;
    local count = para.count;
    if attrib ~= "magic" then
        return;
    end

    -- 已加的魔力点
    local addPoints = PropStatM.getData1(ME.user, "magic_bonus");
    addPoints = addPoints + para.count;
    PropStatM.setData1(ME.user, "magic_bonus", addPoints);

    -- 触发prop
    local props = PropM.fetchProps(ME.user, "magic_bonus");
    for _, prop in ipairs(props) do
        PropM.trigger(ME.user, prop[1], prop[2]);
    end
end

-- 获得魔力提升事件
EventMgr.register("prop_stat/magic", event.BONUS_ATTRIB, handle);